/*=========================================================================
 Copyright (c) 2008, Nokia Corporation and/or its subsidiary(-ies).
 All rights reserved.

 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
 
     * Redistributions of source code must retain the above copyright
       notice, this list of conditions and the following disclaimer.
     * Redistributions in binary form must reproduce the above copyright
       notice, this list of conditions and the following disclaimer in the
       documentation and/or other materials provided with the distribution.
     * Neither the name of the Nokia Corporation and/or its subsidiary(-ies)nor the
       names of its contributors may be used to endorse or promote products
       derived from this software without specific prior written permission.

 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
 THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
 OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 
 TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=========================================================================================*/

#ifndef __ncvMATH_H__
#define __ncvMATH_H__

#include <e32std.h>

#define _Sin(a, b) CNokiaCVMath::SinLT(a, b)
#define _Cos(a, b) CNokiaCVMath::CosLT(a, b)

/**
 * \def Machine epsilon, used in floating point comparisons
 */
const TReal epsilon = 0.000001;

/**
 * \class CNokiaCVMath
 * \brief This class gathers some utility functions in one place.
 * \note Symbian TClass.
 */
class CNokiaCVMath
	{
public:
	/**
	 * \brief Fixed point ceil-function.
	 */
	IMPORT_C static TInt Ceil1616(TInt aFp);
	/**
	 * \brief Fixed point floor-function.
	 */
	IMPORT_C static TInt Floor1616(TInt aFp);
	/**
	 * \brief Fixed point round-function.
	 */
	IMPORT_C static TInt Round1616(TInt aFp);

	/**
	 * \brief Compares two floating point numbers and return ETrue if they are within
	 * machine epsilon of each other.
	 * \return TBool
	 */
	IMPORT_C static TBool IsEqual(TReal aX, TReal aY);

	/**
	 * \brief Computes Sin using lookup table
	 * \param aTrg result value
	 * \param aSrc angle in radians
	 */	
	IMPORT_C static TInt SinLUT_Rad(TReal& aTrg,const TReal& aSrc);

	/**
	 * \brief Computes Sin using lookup table 
	 * \param aTrg result value
	 * \param aSrc angle in degrees
	 */		
	IMPORT_C static TInt SinLUT_Deg(TReal& aTrg,const TInt& aSrc);

	/**
	 * \brief Computes Cos using lookup table
	 * \param aTrg result value
	 * \param aSrc angle in radians
	 */		
	IMPORT_C static TInt CosLUT_Rad(TReal& aTrg,const TReal& aSrc);

	 /*
	 * \brief Computes Cos using lookup table
	 * \param aTrg result value
	 * \param aSrc angle in degrees
	 */
	IMPORT_C static TInt CosLUT_Deg(TReal& aTrg,const TInt& aSrc);

	/**
	 * \brief Computes Tan using lookup table 
	 * \param aTrg result value
	 * \param aSrc angle in radians
	 */			
	IMPORT_C static TInt TanLUT_Rad(TReal& aTrg,const TReal& aSrc);
	
	/**
	 * \brief Computes Tan using lookup table 
	 * \param aTrg result value
	 * \param aSrc angle in degrees
	 */			
	IMPORT_C static TInt TanLUT_Deg(TReal& aTrg,const TInt& aSrc);
	};

#endif
